<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/font-awesome.min.css" rel="stylesheet">
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="js/html5shiv.min.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->
    <style type="text/css">body{padding-top: 0;}</style>
</head>
<body>

<div class="container-fluid">
    <form>
    <table class="table table-striped table-condensed">
        <tbody>
        <!--<tr>
            <th class="text-right">课程CPID</th>
            <td>
                <input type="text" class="form-control" id="video_id" placeholder="课程CPID" name="video_id" value="" required autofocus>
            </td>
        </tr>-->
        <tr>
            <th class="text-right">标题</th>
            <td>
                <input type="text" class="form-control" id="title" placeholder="标题" name="title" value="" required autofocus>
            </td>
        </tr>
        <tr>
            <th class="text-right">能力等级</th>
            <td>
               <input type="text" class="form-control" id="capability" name="capability" value="1"/>
            </td>
        </tr>
        <tr>
            <th class="text-right">code</th>
            <td>
                <input type="text" class="form-control" id="code" name="code" placeholder="code" value="" required>
            </td>
        </tr>
        <tr>
            <th class="text-right">免费</th>
            <td>
            	<select class="form-control" id="is_free" name="is_free">
            		<option value="0">否</option>
            		<option value="1">是</option>
            	</select>
            </td>
        </tr>
        <tr>
            <th class="text-right">CP源地址</th>
            <td>
                <input type="text" class="form-control" id="video_url" name="video_url" placeholder="CP源地址" value="">
            </td>
        </tr>
        <tr>
            <th class="text-right">简介</th>
            <td>
                <input type="text" class="form-control" id="brief" name="brief" placeholder="简介" value="">
            </td>
        </tr>
        <tr>
            <th class="text-right">字幕</th>
            <td>
                <textarea class="form-control" id="dialogs" name="dialogs" rows="4" placeholder="字幕"></textarea>
            </td>
        </tr>
        <tr><th></th><td class="text-right"><button type="button" class="btn btn-primary" id="btn-sub">保存编辑</button></td></tr>
        </tbody>
    </table>
    </form>
</div>


<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/url.min.js"></script>
<script src="js/common.js"></script>
<script language="JavaScript">
    var id = $.url('?id');
    $(function(){
        if(id != null && id > 0){
            api.lessonDetail({id:id});
        }
    })
    $("#btn-sub").click(function(){
//  	var dialogs = JSON.parse($("#dialogs").val());
        var opts = {
            "code":$("#code").val(),
            "title":$("#title").val(),
            "is_free":$("#is_free").val(),
            "video_url":$("#video_url").val(),
            "video_id":$("#video_id").val(),
            "capability":$("#capability").val(),
            "brief":$("#brief").val()
        };
        if($("#dialogs").val() != ""){
        	var dialogs = JSON.parse($("#dialogs").val());
        	opts.dialogs = dialogs;
        }
        if(id != null && id > 0){
            opts.id = id;
        }
//      console.info(opts);
        api.lessonEdit(opts);
    });

</script>
</body>
</html>
